feat/CUS-10727-Added class to swipe based on directions#338
Conversation
📝 WalkthroughWalkthroughThis PR introduces a new Maven addon project for TestSigma that provides a WebAction to perform swipe gestures within a specified element. The project includes Maven configuration, the SwipeWithInElementOffset action implementation supporting directional swipes, and SDK configuration properties. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (3)
swipe_within_element_with_offset/pom.xml (1)
17-17: JUnit Jupiter 5.8.0-M1 is a pre-release milestone version.Consider using a stable GA release (e.g.,
5.10.xor5.11.x) for more reliable test infrastructure.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@swipe_within_element_with_offset/pom.xml` at line 17, The pom defines a pre-release JUnit version via the property junit.jupiter.version; update that property value from 5.8.0-M1 to a stable GA release (for example 5.10.0 or 5.11.0) in the pom.xml so the build uses a supported JUnit Jupiter release, then re-run your build/tests to verify compatibility; look for the junit.jupiter.version property to make this change.swipe_within_element_with_offset/src/main/java/com/testsigma/addons/web/SwipeWithInElementOffset.java (2)
84-106: Hardcoded 10px inset may cause issues for small elements.If the element is smaller than 20px in either dimension, the
insetof 10 can push computed points outside the element bounds or collapse the swipe distance to zero. Consider clamping the inset to a fraction of the element's dimensions.Suggested defensive guard
int inset = 10; + inset = Math.min(inset, elementWidth / 4); + inset = Math.min(inset, elementHeight / 4);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@swipe_within_element_with_offset/src/main/java/com/testsigma/addons/web/SwipeWithInElementOffset.java` around lines 84 - 106, The hardcoded inset=10 in getPointInElement can push points outside small elements; change inset to a defensive value based on the element size (for example compute inset = Math.max(1, Math.min(10, Math.min(elementWidth, elementHeight) / 4))) and then ensure the returned x/y are clamped inside the element bounds (between location.getX() and location.getX()+elementWidth-1, and similarly for Y) so TOP/MIDDLE/BOTTOM/LEFT/RIGHT computations never produce coordinates outside the element.
69-77: Use appropriate log levels for error conditions.Lines 70 and 75 use
logger.infofor exception/error scenarios. These should uselogger.warnorlogger.errorto correctly reflect severity and make log filtering meaningful.Proposed fix
} catch (NoSuchElementException e) { - logger.info("Element not found: " + e.getMessage()); + logger.error("Element not found: " + e.getMessage()); setErrorMessage("Element not found: " + e.getMessage()); result = Result.FAILED; } catch (Exception e) { - logger.info("Error occurred: " + e.getMessage()); + logger.error("Error occurred: " + e.getMessage()); setErrorMessage("Error: " + e.getMessage()); result = Result.FAILED;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@swipe_within_element_with_offset/src/main/java/com/testsigma/addons/web/SwipeWithInElementOffset.java` around lines 69 - 77, Change the logger calls in the exception handlers to use appropriate severity: replace logger.info in the NoSuchElementException catch with logger.warn and replace logger.info in the generic Exception catch with logger.error; update the log calls around the catch blocks that reference NoSuchElementException, Exception, setErrorMessage, result, and Result.FAILED so the warnings/errors correctly reflect severity (and keep existing setErrorMessage(...) and result = Result.FAILED behavior).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@swipe_within_element_with_offset/pom.xml`:
- Around line 42-46: The TestNG dependency block (artifactId "testng") currently
lacks a test scope and will be included in the shaded production JAR; update the
dependency definition for artifactId "testng" (version 6.14.3) to include
<scope>test</scope> so TestNG and its transitive dependencies are only used at
test time and not packaged into the production/shaded artifact.
In
`@swipe_within_element_with_offset/src/main/java/com/testsigma/addons/web/SwipeWithInElementOffset.java`:
- Line 13: The import is wrong: replace java.util.NoSuchElementException with
org.openqa.selenium.NoSuchElementException so the catch in the
SwipeWithInElementOffset class (the try/catch around element lookup / actions
that currently intends to handle Selenium's missing-element case) actually
catches Selenium's exception and returns Result.FAILED; remove the java.util
import if present and ensure the catch clause references
org.openqa.selenium.NoSuchElementException (or a plain NoSuchElementException
after fixing the import).
In
`@swipe_within_element_with_offset/src/main/resources/testsigma-sdk.properties`:
- Line 1: The committed secret JWT in the property testsigma-sdk.api.key must be
removed and rotated: revoke the exposed key immediately, purge it from git
history (e.g., BFG or git filter-repo) so it no longer exists in any commit, and
replace the hardcoded value in testsigma-sdk.properties with a placeholder that
reads the key from an environment variable (e.g., reference TESTSIGMA_API_KEY)
or a file ignored by git; also add the properties file or its containing pattern
to .gitignore and update CI/secret manager to provide the new key.
---
Nitpick comments:
In `@swipe_within_element_with_offset/pom.xml`:
- Line 17: The pom defines a pre-release JUnit version via the property
junit.jupiter.version; update that property value from 5.8.0-M1 to a stable GA
release (for example 5.10.0 or 5.11.0) in the pom.xml so the build uses a
supported JUnit Jupiter release, then re-run your build/tests to verify
compatibility; look for the junit.jupiter.version property to make this change.
In
`@swipe_within_element_with_offset/src/main/java/com/testsigma/addons/web/SwipeWithInElementOffset.java`:
- Around line 84-106: The hardcoded inset=10 in getPointInElement can push
points outside small elements; change inset to a defensive value based on the
element size (for example compute inset = Math.max(1, Math.min(10,
Math.min(elementWidth, elementHeight) / 4))) and then ensure the returned x/y
are clamped inside the element bounds (between location.getX() and
location.getX()+elementWidth-1, and similarly for Y) so
TOP/MIDDLE/BOTTOM/LEFT/RIGHT computations never produce coordinates outside the
element.
- Around line 69-77: Change the logger calls in the exception handlers to use
appropriate severity: replace logger.info in the NoSuchElementException catch
with logger.warn and replace logger.info in the generic Exception catch with
logger.error; update the log calls around the catch blocks that reference
NoSuchElementException, Exception, setErrorMessage, result, and Result.FAILED so
the warnings/errors correctly reflect severity (and keep existing
setErrorMessage(...) and result = Result.FAILED behavior).
| <dependency> | ||
| <groupId>org.testng</groupId> | ||
| <artifactId>testng</artifactId> | ||
| <version>6.14.3</version> | ||
| </dependency> |
There was a problem hiding this comment.
TestNG dependency is missing <scope>test</scope> — it will be shaded into the production jar.
Without the test scope, TestNG (and its transitive dependencies) will be bundled into the shaded jar, bloating it unnecessarily.
Proposed fix
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
+ <scope>test</scope>
</dependency>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <dependency> | |
| <groupId>org.testng</groupId> | |
| <artifactId>testng</artifactId> | |
| <version>6.14.3</version> | |
| </dependency> | |
| <dependency> | |
| <groupId>org.testng</groupId> | |
| <artifactId>testng</artifactId> | |
| <version>6.14.3</version> | |
| <scope>test</scope> | |
| </dependency> |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@swipe_within_element_with_offset/pom.xml` around lines 42 - 46, The TestNG
dependency block (artifactId "testng") currently lacks a test scope and will be
included in the shaded production JAR; update the dependency definition for
artifactId "testng" (version 6.14.3) to include <scope>test</scope> so TestNG
and its transitive dependencies are only used at test time and not packaged into
the production/shaded artifact.
| import org.openqa.selenium.WebElement; | ||
| import org.openqa.selenium.interactions.Actions; | ||
|
|
||
| import java.util.NoSuchElementException; |
There was a problem hiding this comment.
Wrong NoSuchElementException imported — Selenium's element-not-found exceptions will not be caught.
java.util.NoSuchElementException is thrown by iterators/enumerations, not by Selenium. When an element is not found, Selenium throws org.openqa.selenium.NoSuchElementException. The catch block on line 69 will never catch the actual Selenium exception, causing it to propagate uncaught instead of returning Result.FAILED.
Proposed fix
-import java.util.NoSuchElementException;
+import org.openqa.selenium.NoSuchElementException;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import java.util.NoSuchElementException; | |
| import org.openqa.selenium.NoSuchElementException; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@swipe_within_element_with_offset/src/main/java/com/testsigma/addons/web/SwipeWithInElementOffset.java`
at line 13, The import is wrong: replace java.util.NoSuchElementException with
org.openqa.selenium.NoSuchElementException so the catch in the
SwipeWithInElementOffset class (the try/catch around element lookup / actions
that currently intends to handle Selenium's missing-element case) actually
catches Selenium's exception and returns Result.FAILED; remove the java.util
import if present and ensure the catch clause references
org.openqa.selenium.NoSuchElementException (or a plain NoSuchElementException
after fixing the import).
| @@ -0,0 +1 @@ | |||
| testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxM2M5YWYzOS0zMWIwLWM2NDUtMjdhMS0xNDVhMTRjMmFkMTUiLCJ1bmlxdWVJZCI6IjU5NjMiLCJpZGVudGl0eUFjY291bnRVVUlkIjoiYWUwYzE3MDMtNzM4MC1kMjkzLTRiYjQtZDU3Y2ZmNzc1MWM0In0.Y8datKRXZHInIHWmDm9M9rWCZ7HSdRuIxKxW-MkTztarRV_6EFMqYO4yesYW0CGqQZ-HNYiWPvIRmWiVOEGfoA No newline at end of file | |||
There was a problem hiding this comment.
🚨 Secret API key committed to a public repository.
This file contains a hardcoded JWT API key that will be pushed to a public GitHub repository. The JWT payload includes identifiable account information (sub, uniqueId, identityAccountUUId). This key must be:
- Revoked immediately — assume it is compromised once pushed.
- Removed from Git history (e.g., via
git filter-branchor BFG Repo-Cleaner), since deleting the file in a subsequent commit does not remove it from history. - Replaced with an environment variable, CI secret, or a
.propertiesfile listed in.gitignore.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@swipe_within_element_with_offset/src/main/resources/testsigma-sdk.properties`
at line 1, The committed secret JWT in the property testsigma-sdk.api.key must
be removed and rotated: revoke the exposed key immediately, purge it from git
history (e.g., BFG or git filter-repo) so it no longer exists in any commit, and
replace the hardcoded value in testsigma-sdk.properties with a placeholder that
reads the key from an environment variable (e.g., reference TESTSIGMA_API_KEY)
or a file ignored by git; also add the properties file or its containing pattern
to .gitignore and update CI/secret manager to provide the new key.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
swipe_inside_element_with_direction/pom.xml (1)
42-46: TestNG dependency missing<scope>test</scope>.This will be included in the shaded JAR via maven-shade-plugin, bloating the artifact. If it's only used for tests, add test scope.
Proposed fix
<dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.14.3</version> + <scope>test</scope> </dependency>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@swipe_inside_element_with_direction/pom.xml` around lines 42 - 46, The TestNG dependency (groupId org.testng, artifactId testng, version 6.14.3) lacks a test scope and is therefore pulled into the shaded JAR; update the dependency declaration for org.testng:testng:6.14.3 to include <scope>test</scope> so Maven treats it as a test-only dependency and the maven-shade-plugin will not package it into the final artifact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@swipe_inside_element_with_direction/src/main/java/com/testsigma/addons/web/SwipeWithInElement.java`:
- Line 13: The import of java.util.NoSuchElementException is incorrect for
Selenium handling; update the import to
org.openqa.selenium.NoSuchElementException (and remove the java.util import) so
the catch in SwipeWithInElement that currently intends to handle
element-not-found exceptions will actually catch Selenium's exception type;
ensure any catch blocks referencing NoSuchElementException (in methods like the
swipe/execute logic) remain unchanged so they now reference the Selenium
exception class.
---
Nitpick comments:
In `@swipe_inside_element_with_direction/pom.xml`:
- Around line 42-46: The TestNG dependency (groupId org.testng, artifactId
testng, version 6.14.3) lacks a test scope and is therefore pulled into the
shaded JAR; update the dependency declaration for org.testng:testng:6.14.3 to
include <scope>test</scope> so Maven treats it as a test-only dependency and the
maven-shade-plugin will not package it into the final artifact.
| import org.openqa.selenium.WebElement; | ||
| import org.openqa.selenium.interactions.Actions; | ||
|
|
||
| import java.util.NoSuchElementException; |
There was a problem hiding this comment.
Wrong NoSuchElementException import — Selenium's exception will never be caught by the dedicated handler.
java.util.NoSuchElementException is not the same as org.openqa.selenium.NoSuchElementException. The catch block on line 69 targets the java.util variant, so Selenium's "element not found" exception will bypass it and fall into the generic Exception catch instead, losing the specific error message.
Proposed fix
-import java.util.NoSuchElementException;
+import org.openqa.selenium.NoSuchElementException;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import java.util.NoSuchElementException; | |
| import org.openqa.selenium.NoSuchElementException; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@swipe_inside_element_with_direction/src/main/java/com/testsigma/addons/web/SwipeWithInElement.java`
at line 13, The import of java.util.NoSuchElementException is incorrect for
Selenium handling; update the import to
org.openqa.selenium.NoSuchElementException (and remove the java.util import) so
the catch in SwipeWithInElement that currently intends to handle
element-not-found exceptions will actually catch Selenium's exception type;
ensure any catch blocks referencing NoSuchElementException (in methods like the
swipe/execute logic) remain unchanged so they now reference the Selenium
exception class.
Publish this addon as PUBLIC
Addon Name: Swipe Inside Element With Direction
Jarvis Link: https://jarvis.testsigma.com/ui/tenants/2817/addons
Jira : https://testsigma.atlassian.net/browse/CUS-10727
Added class to swipe based on directions
Summary by CodeRabbit
Release Notes